<?php
  ob_start();
  session_start();
  ini_set('display_errors','0');

  if(file_exists('../conf/db.php') && !$_SESSION['installer']){
    die();
  }
  if(!isset($_SESSION['siteurl'])){
    $_SESSION['siteurl'] = substr('http://'.$_SERVER['SERVER_NAME'].$_SERVER["REQUEST_URI"],0,-20);
  }

  if(!isset($_SESSION['first_time'])){
    $_SESSION['first_time'] = 1;
  }
  require_once 'core.php';
  if(!isset($_SESSION['lang'])){
    $lang = 'en';
  } else {
    $lang = $_SESSION['lang'];
  }
  require_once 'lang/'.$lang.'/main.php';

  if(!isset($_GET['step'])){
    $step = 'main';
  } else {
    $step = $_GET['step'];
  }

  if(isset($_POST['process'])){
    sessionize_inputs();
    if(file_exists('process/'.$step.'.php')){
      require_once 'process/'.$step.'.php';
    }
  }

  require_once 'views/head.php';


  switch($step){
    case 'main':
      require_once 'views/forms/main.php';
    break;
    case 'db':
      require_once 'views/forms/db.php';
    break;
    case 'basic':
      require_once 'views/forms/basic.php';
    break;
    case 'personal':
      require_once 'views/forms/personal.php';
    break;
    case 'finish':
      require_once 'views/forms/finish.php';
    break;
    default:
      require_once 'views/forms/main.php';
    break;
  }
  require_once 'views/foot.php';
?>
